import http from '@/http/index';

export type TokenParams = {
  orderId: string;
  fileName: string;
};

export type TokenResult = {
  resourceId: number;
  resourceType: number;
  domain: string;
  uploadKey: string;
  uploadToken: string;
};

// /elcapi/assapp/device/alarm/order/genOfflineOrderImageUploadToken
export function genOfflineOrderImageUploadToken(data: TokenParams) {
  return http.post<TokenResult>(
    '/assapp/device/alarm/order/genOfflineOrderImageUploadToken',
    data,
    {
      showLoading: false,
    }
  );
}

export function genOfflineOrderVoiceUploadToken(data: TokenParams) {
  return http.post<TokenResult>(
    '/assapp/device/alarm/order/genOfflineOrderVoiceUploadToken',
    data,
    {
      showLoading: false,
    }
  );
}

type TokenResult2 = {
  requestId: string;
  resources: [
    {
      type: string;
      resource: {
        resourceId: number;
        resourceType: number;
        domain: string;
        uploadKey: string;
        uploadToken: string;
      };
    }
  ];
};
// /elcapi/assapp/elder/genOcrIdCardUploadToken
export function genOcrIdCardUploadToken(type: string) {
  return http.post<TokenResult2>(
    '/assapp/elder/genOcrIdCardUploadToken',
    {
      type,
    },
    {
      showLoading: false,
    }
  );
}
